/**
 * this is where all the libraries used in this class are imported
 */
import javax.swing.JOptionPane; // $codepro.audit.disable unnecessaryImport

/**
*this class tells the player the news for the planet
*
*@author Anna
*@version 1.0
*/
public class News { // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString
	
	/**
	 * Field events
	 */
	private String[] events; // $codepro.audit.disable variableShouldBeFinal
	
	/**
	 * Field index
	 */
	private int index; // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.unassignedField
	
	/**
	 * Field model
	 */
	private Model model; // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.unassignedField
	
	/**
	 * Field view
	 */
	private View view; // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.unassignedField
	
	/**
	*this method creates an array of strings for the news
	*
	* @param index 
	* @param model
	* @param view
	*/
	public News(int index, Model model, View view){
		this.index=index;
		this.model=model;
		this.view=view;
		events=GoodsInfo.Ie;
	}
	
	/**
	 * this method shows the news for the planet
	 */
	public void show(){ // $codepro.audit.disable emptyMethod
		int response= JOptionPane.showConfirmDialog(view,  // $codepro.audit.disable variableShouldBeFinal -->
				"It costs 5 credits for a piece of news.\n Do you want to buy news?");
		if(response == JOptionPane.YES_OPTION){
			if(index == -1){
				JOptionPane.showMessageDialog(view, 
						"There is no special events on this planet!");
			}
		}
			else{ 
				JOptionPane.showMessageDialog(view, events[index]);
		}
	}
}
